package com.xkdx.caipiao.util;

import java.security.MessageDigest;

public class Md5Utils {
	public static String md5(String str) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] digest = md.digest(str.getBytes());
            StringBuilder sb = new StringBuilder();
            String hexString;
            for (byte b : digest) {
                int d = b & 0xff;
                hexString = Integer.toHexString(d);
                if (hexString.length() < 2) {
                    sb.append(0);
                }
                sb.append(hexString);
            }
            return sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
